package com.zhengyisky.exception;

import com.zhengyisky.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Component
@ControllerAdvice
@Slf4j
public class ExceptionCatch {

    @ExceptionHandler
    @ResponseBody
    public Result catchException(Exception e){
        log.error("捕获到了异常。。。。");
        e.printStackTrace();
        return Result.error(e.getMessage());
    }
}
